<!--
 * @Description: useClipboard（剪贴板）
 * @Author: r_yuesheng
 * @Date: 2022-12-23 16:33:53
 * @LastEditTime: 2022-12-28 15:02:13
 * @LastEditors: r_yuesheng
-->
<template>
  <div>
    <el-input v-model="content"></el-input>
    <el-button @click="copyContent()" type="primary" class="mt20 w200">
      复制
    </el-button>
  </div>
</template>
<script>
import { reactive, toRefs } from 'vue';
import { useClipboard } from '@vueuse/core';
export default {
  name: '',
  props: {},
  components: {},
  setup(props, { emit }) {
    function initState() {
      return {
        content: '',
      };
    }
    const state = reactive(initState());
    function copyContent() {
      const { copy } = useClipboard();
      copy(state.content);
    }

    return {
      ...toRefs(state),
      copyContent,
    };
  },
};
</script>